package com.flute.icrawler.framework.framework;

import java.rmi.RemoteException;

import com.flute.icrawler.app.processor.AbstractProcessor;
import com.flute.icrawler.config.CrawlConfig;
import com.flute.icrawler.config.CrawlConfigUtil;
import com.flute.icrawler.framework.processor.Print2Processor;
import com.flute.icrawler.framework.processor.Print3Processor;
import com.flute.icrawler.framework.processor.Print4Processor;
import com.flute.icrawler.framework.processor.PrintProcessor;

public class JobControllerTest {
	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		JobSetttings settings = new JobSetttings();
		ProcessorDependency pd = new ProcessorDependency();
		CrawlConfig crawlConfig = CrawlConfigUtil.newCrawlConfig("crawler.xml");
		
		PrintProcessor printProcessor = new PrintProcessor();
		Print2Processor print2Processor = new Print2Processor();
		Print3Processor print3Processor = new Print3Processor();
		Print4Processor print4Processor = new Print4Processor();
		
		pd.addProcessor(new AbstractProcessor[] { printProcessor,
				print4Processor, print3Processor,
				print2Processor });
		
		pd.addDependency(printProcessor, print4Processor);
		pd.addDependency(print3Processor,print2Processor);

		settings.addSeed(new Seed("http://www.163.com1"));
		settings.addSeed(new Seed("http://www.163.com2"));
		settings.addSeed(new Seed("http://update-url"));
		
		
		// settings.addSeed(new Seed("http://www.163.com3"));
		// settings.addSeed(new Seed("http://www.163.com4"));
		// settings.addSeed(new Seed("http://www.163.com5"));
		// settings.addSeed(new Seed("http://www.163.com6"));
		// settings.addSeed(new Seed("http://www.163.com7"));
		// settings.addSeed(new Seed("http://www.163.com8"));
		// settings.addSeed(new Seed("http://www.163.com9"));
		// settings.addSeed(new Seed("http://www.163.com11"));
		// settings.addSeed(new Seed("http://www.163.com12"));
		// settings.addSeed(new Seed("http://www.163.com13"));
		// settings.addSeed(new Seed("http://www.163.com14"));
		// settings.addSeed(new Seed("http://www.163.com15"));
		// settings.addSeed(new Seed("http://www.163.com16"));
		// settings.addSeed(new Seed("http://www.163.com17"));
		// settings.addSeed(new Seed("http://www.163.com18"));
		// settings.addSeed(new Seed("http://www.163.com19"));
		// JobController controller = new JobController(settings);
		// controller.start();
		JobServerController serverController = null;
	
		try {
			serverController = new JobServerController(crawlConfig);
			serverController.addChildExecutor(new JobChildController(
					serverController.getCrawlUrlPool(),crawlConfig));
		} catch (RemoteException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		serverController.start();
	}
}